//
//  HZL_AllCollectionViewCell.m
//  B_Project
//
//  Created by 胡佳俊 on 15/11/30.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_AllCollectionViewCell.h"

@interface HZL_AllCollectionViewCell ()
@property (nonatomic, retain) UIImageView *imgView;
@property (nonatomic, retain) UILabel *nameLabel;

@end
@implementation HZL_AllCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imgView];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.imgView.frame = CGRectMake(20, 0, 40, 40);
    self.nameLabel.frame = CGRectMake(0, 40, layoutAttributes.size.width, 20);
    
    
}
- (void)setModel:(HZL_AllModel *)model
{
    if (_model != model) {
        _model = model;
    }
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:self.model.img] placeholderImage:nil];
    self.nameLabel.text = self.model.name;
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:15];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
